package sql

import org.apache.spark.sql.catalog.{Database, Table}
import org.apache.spark.sql.{Dataset, SparkSession}

object sql01_hive {

  def main(args: Array[String]): Unit = {


    val ss: SparkSession = SparkSession
      .builder()
      .appName("tets")
      .master("local[*]")
      .enableHiveSupport()
      .config("hive.metastore.uris", "thrift://node1:9083")
      .getOrCreate()


    val dbDs: Dataset[Database] = ss.catalog.listDatabases()
    dbDs.show()


    ss.sql("create table t1(a String)")


    val tableDs: Dataset[Table] = ss.catalog.listTables("default")
    tableDs.show()
  }

}
